#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cstring>
using namespace std;
int main()
{
    char str1[31], str2[31];
    int t;
    scanf("%d", &t);
    int arr[51][27];
    int k;
    while (t--) {
        scanf("%s%s%d", str1, str2, &k);
        memset(arr, 0, sizeof(arr));
        for (int i = 0; str1[i] != '\0'; i++) {
            arr[0][str1[i] - 'a']++;
        }
        for (int i = 0; str2[i] != '\0'; i++) {
            arr[1][str2[i] - 'a']++;
        }
        for (int i = 2; i <= k; i++) {
            for (int j = 0; j < 26; j++) {
                arr[i][j] = arr[i - 1][j] + arr[i - 2][j];
            }
        }3
        for (int i = 0; i < 26; i++) {
            cout << (char)(i + 'a') << ":" << arr[k][i] << endl;
        }
        cout << endl;
    }
    return 0;
}